package cloud.tianai.ram.policy.common.model.dto;


import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

/**
 * @Author: 天爱有情
 * @date 2022/4/20 15:19
 * @Description type 定义
 */
@Data
@NoArgsConstructor
public class TypeDefinition {

    private String type;
    private String description;
    private String from;

    public TypeDefinition(String type, String description) {
        this.type = type;
        this.description = description;
        this.from = "local";
    }

    public TypeDefinition(String type, String description, String from) {
        this.type = type;
        this.description = description;
        this.from = from;
    }

    public boolean equals(String type) {
        return this.type.equalsIgnoreCase(type);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TypeDefinition that = (TypeDefinition) o;
        return type.equalsIgnoreCase(that.type);
    }

    @Override
    public int hashCode() {
        return Objects.hash(type);
    }
}
